
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Store Setup · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.2">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="Actions.html" />
    
    
    <link rel="prev" href="OrganizingState.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Read Me
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../introduction/">
            
                <a href="../introduction/">
            
                    
                    Introduction
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../introduction/Motivation.html">
            
                <a href="../introduction/Motivation.html">
            
                    
                    Motivation
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../introduction/CoreConcepts.html">
            
                <a href="../introduction/CoreConcepts.html">
            
                    
                    Core Concepts
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../introduction/ThreePrinciples.html">
            
                <a href="../introduction/ThreePrinciples.html">
            
                    
                    Three Principles
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../introduction/PriorArt.html">
            
                <a href="../introduction/PriorArt.html">
            
                    
                    Prior Art
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../introduction/Ecosystem.html">
            
                <a href="../introduction/Ecosystem.html">
            
                    
                    Ecosystem
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../introduction/Examples.html">
            
                <a href="../introduction/Examples.html">
            
                    
                    Examples
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../basics/">
            
                <a href="../basics/">
            
                    
                    Basics
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../basics/Actions.html">
            
                <a href="../basics/Actions.html">
            
                    
                    Actions
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../basics/Reducers.html">
            
                <a href="../basics/Reducers.html">
            
                    
                    Reducers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../basics/Store.html">
            
                <a href="../basics/Store.html">
            
                    
                    Store
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../basics/DataFlow.html">
            
                <a href="../basics/DataFlow.html">
            
                    
                    Data Flow
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../basics/UsageWithReact.html">
            
                <a href="../basics/UsageWithReact.html">
            
                    
                    Usage with React
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../basics/ExampleTodoList.html">
            
                <a href="../basics/ExampleTodoList.html">
            
                    
                    Example: Todo List
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../advanced/">
            
                <a href="../advanced/">
            
                    
                    Advanced
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../advanced/AsyncActions.html">
            
                <a href="../advanced/AsyncActions.html">
            
                    
                    Async Actions
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../advanced/AsyncFlow.html">
            
                <a href="../advanced/AsyncFlow.html">
            
                    
                    Async Flow
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../advanced/Middleware.html">
            
                <a href="../advanced/Middleware.html">
            
                    
                    Middleware
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../advanced/UsageWithReactRouter.html">
            
                <a href="../advanced/UsageWithReactRouter.html">
            
                    
                    Usage with React Router
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../advanced/ExampleRedditAPI.html">
            
                <a href="../advanced/ExampleRedditAPI.html">
            
                    
                    Example: Reddit API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" >
            
                <span>
            
                    
                    Next Steps
            
                </span>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../recipes/">
            
                <a href="../recipes/">
            
                    
                    Recipes
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../recipes/MigratingToRedux.html">
            
                <a href="../recipes/MigratingToRedux.html">
            
                    
                    Migrating to Redux
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../recipes/UsingObjectSpreadOperator.html">
            
                <a href="../recipes/UsingObjectSpreadOperator.html">
            
                    
                    Using Object Spread Operator
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../recipes/ReducingBoilerplate.html">
            
                <a href="../recipes/ReducingBoilerplate.html">
            
                    
                    Reducing Boilerplate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../recipes/ServerRendering.html">
            
                <a href="../recipes/ServerRendering.html">
            
                    
                    Server Rendering
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../recipes/WritingTests.html">
            
                <a href="../recipes/WritingTests.html">
            
                    
                    Writing Tests
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="../recipes/ComputingDerivedData.html">
            
                <a href="../recipes/ComputingDerivedData.html">
            
                    
                    Computing Derived Data
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.7" data-path="../recipes/ImplementingUndoHistory.html">
            
                <a href="../recipes/ImplementingUndoHistory.html">
            
                    
                    Implementing Undo History
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.8" data-path="../recipes/IsolatingSubapps.html">
            
                <a href="../recipes/IsolatingSubapps.html">
            
                    
                    Isolating Subapps
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.9" data-path="../recipes/StructuringReducers.html">
            
                <a href="../recipes/StructuringReducers.html">
            
                    
                    Structuring Reducers
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.9.1" data-path="../recipes/reducers/PrerequisiteConcepts.html">
            
                <a href="../recipes/reducers/PrerequisiteConcepts.html">
            
                    
                    Prerequisite Concepts
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.9.2" data-path="../recipes/reducers/BasicReducerStructure.html">
            
                <a href="../recipes/reducers/BasicReducerStructure.html">
            
                    
                    Basic Reducer Structure
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.9.3" data-path="../recipes/reducers/SplittingReducerLogic.html">
            
                <a href="../recipes/reducers/SplittingReducerLogic.html">
            
                    
                    Splitting Reducer Logic
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.9.4" data-path="../recipes/reducers/RefactoringReducersExample.html">
            
                <a href="../recipes/reducers/RefactoringReducersExample.html">
            
                    
                    Refactoring Reducers Example
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.9.5" data-path="../recipes/reducers/UsingCombineReducers.html">
            
                <a href="../recipes/reducers/UsingCombineReducers.html">
            
                    
                    Using combineReducers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.9.6" data-path="../recipes/reducers/BeyondCombineReducers.html">
            
                <a href="../recipes/reducers/BeyondCombineReducers.html">
            
                    
                    Beyond combineReducers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.9.7" data-path="../recipes/reducers/NormalizingStateShape.html">
            
                <a href="../recipes/reducers/NormalizingStateShape.html">
            
                    
                    Normalizing State Shape
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.9.8" data-path="../recipes/reducers/UpdatingNormalizedData.html">
            
                <a href="../recipes/reducers/UpdatingNormalizedData.html">
            
                    
                    Updating Normalized Data
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.9.9" data-path="../recipes/reducers/ReusingReducerLogic.html">
            
                <a href="../recipes/reducers/ReusingReducerLogic.html">
            
                    
                    Reusing Reducer Logic
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.9.10" data-path="../recipes/reducers/ImmutableUpdatePatterns.html">
            
                <a href="../recipes/reducers/ImmutableUpdatePatterns.html">
            
                    
                    Immutable Update Patterns
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.9.11" data-path="../recipes/reducers/InitializingState.html">
            
                <a href="../recipes/reducers/InitializingState.html">
            
                    
                    Initializing State
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5.10" data-path="../recipes/UsingImmutableJS.html">
            
                <a href="../recipes/UsingImmutableJS.html">
            
                    
                    Using Immutable.JS with Redux
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../FAQ.html">
            
                <a href="../FAQ.html">
            
                    
                    FAQ
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="General.html">
            
                <a href="General.html">
            
                    
                    General
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="Reducers.html">
            
                <a href="Reducers.html">
            
                    
                    Reducers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="OrganizingState.html">
            
                <a href="OrganizingState.html">
            
                    
                    Organizing State
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.6.4" data-path="StoreSetup.html">
            
                <a href="StoreSetup.html">
            
                    
                    Store Setup
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="Actions.html">
            
                <a href="Actions.html">
            
                    
                    Actions
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="ImmutableData.html">
            
                <a href="ImmutableData.html">
            
                    
                    Immutable Data
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="CodeStructure.html">
            
                <a href="CodeStructure.html">
            
                    
                    Code Structure
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="Performance.html">
            
                <a href="Performance.html">
            
                    
                    Performance
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="ReactRedux.html">
            
                <a href="ReactRedux.html">
            
                    
                    React Redux
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.10" data-path="Miscellaneous.html">
            
                <a href="Miscellaneous.html">
            
                    
                    Miscellaneous
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../Troubleshooting.html">
            
                <a href="../Troubleshooting.html">
            
                    
                    Troubleshooting
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../Glossary.html">
            
                <a href="../Glossary.html">
            
                    
                    Glossary
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../api/">
            
                <a href="../api/">
            
                    
                    API Reference
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../api/createStore.html">
            
                <a href="../api/createStore.html">
            
                    
                    createStore
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../api/Store.html">
            
                <a href="../api/Store.html">
            
                    
                    Store
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../api/combineReducers.html">
            
                <a href="../api/combineReducers.html">
            
                    
                    combineReducers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4" data-path="../api/applyMiddleware.html">
            
                <a href="../api/applyMiddleware.html">
            
                    
                    applyMiddleware
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.5" data-path="../api/bindActionCreators.html">
            
                <a href="../api/bindActionCreators.html">
            
                    
                    bindActionCreators
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.6" data-path="../api/compose.html">
            
                <a href="../api/compose.html">
            
                    
                    compose
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../CHANGELOG.md">
            
                <span>
            
                    
                    Change Log
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../PATRONS.md">
            
                <span>
            
                    
                    Patrons
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../Feedback.html">
            
                <a href="../Feedback.html">
            
                    
                    Feedback
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >Store Setup</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="redux-faq-store-setup">Redux FAQ: Store Setup</h1>
<h2 id="table-of-contents">Table of Contents</h2>
<ul>
<li><a href="#store-setup-multiple-stores">Can or should I create multiple stores? Can I import my store directly, and use it in components myself?</a> </li>
<li><a href="#store-setup-middleware-chains">Is it OK to have more than one middleware chain in my store enhancer? What is the difference between next and dispatch in a middleware function?</a> </li>
<li><a href="#store-setup-subscriptions">How do I subscribe to only a portion of the state? Can I get the dispatched action as part of the subscription?</a> </li>
</ul>
<h2 id="store-setup">Store Setup</h2>
<p><a id="store-setup-multiple-stores"></a></p>
<h3 id="can-or-should-i-create-multiple-stores-can-i-import-my-store-directly-and-use-it-in-components-myself">Can or should I create multiple stores? Can I import my store directly, and use it in components myself?</h3>
<p>The original Flux pattern describes having multiple &#x201C;stores&#x201D; in an app, each one holding a different area of domain data. This can introduce issues such as needing to have one <a href="../Glossary.html#store" class="glossary-term" title="">store</a> &#x201C;<code>waitFor</code>&#x201D; another <a href="../Glossary.html#store" class="glossary-term" title="">store</a> to update. This is not necessary in Redux because the separation between data domains is already achieved by splitting a single <a href="../Glossary.html#reducer" class="glossary-term" title="">reducer</a> into smaller reducers.</p>
<p>As with several other questions, it is <em>possible</em> to create multiple distinct Redux stores in a page, but the intended pattern is to have only a single <a href="../Glossary.html#store" class="glossary-term" title="">store</a>. Having a single <a href="../Glossary.html#store" class="glossary-term" title="">store</a> enables using the Redux DevTools, makes persisting and rehydrating data simpler, and simplifies the subscription logic.</p>
<p>Some valid reasons for using multiple stores in Redux might include:</p>
<ul>
<li>Solving a performance issue caused by too frequent updates of some part of the <a href="../Glossary.html#state" class="glossary-term" title="">state</a>, when confirmed by profiling the app.</li>
<li>Isolating a Redux app as a component in a bigger application, in which case you might want to create a <a href="../Glossary.html#store" class="glossary-term" title="">store</a> per root component instance.</li>
</ul>
<p>However, creating new stores shouldn&apos;t be your first instinct, especially if you come from a Flux background. Try <a href="../Glossary.html#reducer" class="glossary-term" title="">reducer</a> composition first, and only use multiple stores if it doesn&apos;t solve your problem.</p>
<p>Similarly, while you <em>can</em> reference your <a href="../Glossary.html#store" class="glossary-term" title="">store</a> instance by importing it directly, this is not a recommended pattern in Redux. If you create a <a href="../Glossary.html#store" class="glossary-term" title="">store</a> instance and export it from a module, it will become a singleton. This means it will be harder to isolate a Redux app as a component of a larger app, if this is ever necessary, or to enable server rendering, because on the server you want to create separate <a href="../Glossary.html#store" class="glossary-term" title="">store</a> instances for every request.</p>
<p>With <a href="https://github.com/reactjs/react-redux" target="_blank">React Redux</a>, the wrapper classes generated by the <code>connect()</code> function do actually look for <code>props.store</code> if it exists, but it&apos;s best if you wrap your root component in <code>&lt;Provider store={store}&gt;</code> and let React Redux worry about passing the <a href="../Glossary.html#store" class="glossary-term" title="">store</a> down. This way components don&apos;t need to worry about importing a <a href="../Glossary.html#store" class="glossary-term" title="">store</a> module, and isolating a Redux app or enabling server rendering is much easier to do later.</p>
<h4 id="further-information">Further information</h4>
<p><strong>Documentation</strong></p>
<ul>
<li><a href="../docs/api/Store.md">API: Store</a></li>
</ul>
<p><strong>Discussions</strong></p>
<ul>
<li><a href="https://github.com/reactjs/redux/issues/1436" target="_blank">#1346: Is it bad practice to just have a &apos;stores&apos; directory?</a></li>
<li><a href="http://stackoverflow.com/questions/33619775/redux-multiple-stores-why-not" target="_blank">Stack Overflow: Redux multiple stores, why not?</a></li>
<li><a href="http://stackoverflow.com/questions/35667249/accessing-redux-state-in-an-action-creator" target="_blank">Stack Overflow: Accessing Redux state in an action creator</a></li>
<li><a href="https://gist.github.com/gaearon/eeee2f619620ab7b55673a4ee2bf8400" target="_blank">Gist: Breaking out of Redux paradigm to isolate apps</a></li>
</ul>
<p><a id="store-setup-middleware-chains"></a></p>
<h3 id="is-it-ok-to-have-more-than-one-middleware-chain-in-my-store-enhancer-what-is-the-difference-between-next-and-dispatch-in-a-middleware-function">Is it OK to have more than one middleware chain in my store enhancer? What is the difference between <code>next</code> and <code>dispatch</code> in a middleware function?</h3>
<p>Redux <a href="../Glossary.html#middleware" class="glossary-term" title="">middleware</a> act like a linked list. Each <a href="../Glossary.html#middleware" class="glossary-term" title="">middleware</a> function can either call <code>next(action)</code> to pass an <a href="../Glossary.html#action" class="glossary-term" title="">action</a> along to the next <a href="../Glossary.html#middleware" class="glossary-term" title="">middleware</a> in line, call <code>dispatch(action)</code> to restart the processing at the beginning of the list, or do nothing at all to stop the <a href="../Glossary.html#action" class="glossary-term" title="">action</a> from being processed further.</p>
<p>This chain of <a href="../Glossary.html#middleware" class="glossary-term" title="">middleware</a> is defined by the arguments passed to the <code>applyMiddleware</code> function used when creating a <a href="../Glossary.html#store" class="glossary-term" title="">store</a>. Defining multiple chains will not work correctly, as they would have distinctly different <code>dispatch</code> references and the different chains would effectively be disconnected.</p>
<h4 id="further-information">Further information</h4>
<p><strong>Documentation</strong></p>
<ul>
<li><a href="../docs/advanced/Middleware.md">Advanced: Middleware</a></li>
<li><a href="../docs/api/applyMiddleware.md">API: applyMiddleware</a></li>
</ul>
<p><strong>Discussions</strong></p>
<ul>
<li><a href="https://github.com/reactjs/redux/issues/1051" target="_blank">#1051: Shortcomings of the current applyMiddleware and composing createStore</a></li>
<li><a href="https://medium.com/@meagle/understanding-87566abcfb7a" target="_blank">Understanding Redux Middleware</a></li>
<li><a href="http://blog.krawaller.se/posts/exploring-redux-middleware/" target="_blank">Exploring Redux Middleware</a></li>
</ul>
<p><a id="store-setup-subscriptions"></a></p>
<h3 id="how-do-i-subscribe-to-only-a-portion-of-the-state-can-i-get-the-dispatched-action-as-part-of-the-subscription">How do I subscribe to only a portion of the state? Can I get the dispatched action as part of the subscription?</h3>
<p>Redux provides a single <code>store.subscribe</code> method for notifying listeners that the <a href="../Glossary.html#store" class="glossary-term" title="">store</a> has updated. Listener callbacks do not receive the current <a href="../Glossary.html#state" class="glossary-term" title="">state</a> as an argument&#x2014;it is simply an indication that <em>something</em> has changed. The subscriber logic can then call <code>getState()</code> to get the current <a href="../Glossary.html#state" class="glossary-term" title="">state</a> value.</p>
<p>This API is intended as a low-level primitive with no dependencies or complications, and can be used to build higher-level subscription logic. UI bindings such as React Redux can create a subscription for each connected component. It is also possible to write functions that can intelligently compare the old <a href="../Glossary.html#state" class="glossary-term" title="">state</a> vs the new <a href="../Glossary.html#state" class="glossary-term" title="">state</a>, and execute additional logic if certain pieces have changed. Examples include <a href="https://github.com/jprichardson/redux-watch" target="_blank">redux-watch</a> and <a href="https://github.com/ashaffer/redux-subscribe" target="_blank">redux-subscribe</a> which offer different approaches to specifying subscriptions and handling changes.</p>
<p>The new <a href="../Glossary.html#state" class="glossary-term" title="">state</a> is not passed to the listeners in order to simplify implementing <a href="../Glossary.html#store" class="glossary-term" title="">store</a> enhancers such as the Redux DevTools. In addition, subscribers are intended to react to the <a href="../Glossary.html#state" class="glossary-term" title="">state</a> value itself, not the <a href="../Glossary.html#action" class="glossary-term" title="">action</a>. <a href="../Glossary.html#middleware" class="glossary-term" title="">Middleware</a> can be used if the <a href="../Glossary.html#action" class="glossary-term" title="">action</a> is important and needs to be handled specifically.</p>
<h4 id="further-information">Further information</h4>
<p><strong>Documentation</strong></p>
<ul>
<li><a href="../docs/basics/Store.md">Basics: Store</a></li>
<li><a href="../docs/api/Store.md">API: Store</a></li>
</ul>
<p><strong>Discussions</strong></p>
<ul>
<li><a href="https://github.com/reactjs/redux/issues/303" target="_blank">#303: subscribe API with state as an argument</a></li>
<li><a href="https://github.com/reactjs/redux/issues/580" target="_blank">#580: Is it possible to get action and state in store.subscribe?</a></li>
<li><a href="https://github.com/reactjs/redux/issues/922" target="_blank">#922: Proposal: add subscribe to middleware API</a></li>
<li><a href="https://github.com/reactjs/redux/issues/1057" target="_blank">#1057: subscribe listener can get action param?</a></li>
<li><a href="https://github.com/reactjs/redux/issues/1300" target="_blank">#1300: Redux is great but major feature is missing</a></li>
</ul>
<p><strong>Libraries</strong></p>
<ul>
<li><a href="https://github.com/markerikson/redux-ecosystem-links/blob/master/store.md#store-change-subscriptions" target="_blank">Redux Addons Catalog: Store Change Subscriptions</a></li>
</ul>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="OrganizingState.html" class="navigation navigation-prev " aria-label="Previous page: Organizing State">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="Actions.html" class="navigation navigation-next " aria-label="Next page: Actions">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Store Setup","level":"1.6.4","depth":2,"next":{"title":"Actions","level":"1.6.5","depth":2,"path":"faq/Actions.md","ref":"./faq/Actions.md","articles":[]},"previous":{"title":"Organizing State","level":"1.6.3","depth":2,"path":"faq/OrganizingState.md","ref":"./faq/OrganizingState.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"faq/StoreSetup.md","mtime":"2017-03-13T14:28:11.319Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-03-15T14:47:19.389Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

